# -*- coding: utf-8 -*-
import sys
sys.path.append("..")

import xlrd
import json
import pandas as pd
import numpy as np


class BaoyuCal(object):
    """
    """

    def testBaoyuCal(self):
        #先生成一个dataframe
        df = {"col_01" : [112.8,	115.2,	110.2,	113.8,	113.8,	115,	115.6,	113.6,	115.1,	114.1,	117.4],
              "col_02" : [110.8,	114.4,	112.6,	115,	114.6,	112.6,	114.8,	113.8,	114.2,	114.8,	118.5],
              "col_03" : [116.2,	115.4,	114.9,	114.1,	112.8,	115.6,	115,	114.8,	115,	114.9,	120.5],
              "col_04" : [113.2,	110,	114.4,	115.4,	117.2,	114.8,	112.1,	114.5,	113.9,	115.4,	116.4],
              "col_05" : [113.2,	117.5,	114.5,	116.3,	113.2,	116.3,	115.9,	117.3,	115.6,	116.4,	118.2],
              "col_06" : [116.4,	116.8,	116.9,	115.6,	118.5,	115,	115.4,	116.4,	116.3,	116.8,	116.2],
              "col_07" : [117.9,	112.5,	115.8,	115.5,	117.2,	115.6,	116.4,	116.5,	117.1,	117.6,	0],
              "col_08" : [115.1,	118.2,	118.8,	116.4,	118.3,	117.4,	115.9,	117.2,	119.4,	117.3,	0],
              "col_09" : [116.6,	121.5,	114.9,	116.7,	116.8,	115.9,	117.6,	117.8,	116,	113.8,	0],
              "col_10" : [118.4,	115.8,	118.8,	116.5,	115.3,	116.2,	115.5,	115,	114.6,	115.5,	0],
              "col_11" : [114.4,	113.4,	114.6,	119.6,	115.4,	150,	0,	0,	0,	0,	0]}
        df = pd.DataFrame(df)
        #print(df)

        #计算各行数据总和并作为新列添加到末尾
        df[ 'col_sum' ] = df.apply(lambda x: x.sum(), axis = 1)
        #计算各列数据总和并作为新行添加到末尾
        df.loc[ 'row_sum' ] = df.apply(lambda x: x.sum())
        print(df)
        total = df.iloc[11,11]
        print("==========================虚重:", total, "斤")

        x = 10/0.97 + 1 #( x - 1) * 0.97 = 10  #每篮子鲍鱼的虚重应不少于x斤，才能确保鱼的净重不少于10斤。这样篮子才能扣1斤的重量，水是每10斤鱼扣0.3斤水！
        print("==========================权重=", x, "\t权重:意思是每篮子鲍鱼应该装满11.31斤，篮子才能扣1斤的重量。") 
        total *= 10/x #每篮子鱼的虚重为x斤，才能确保鱼的净重为10斤
        print("==========================净重:", total, "斤")
        total *= 36 #每斤36元
        print("==========================合计:", total, "元") 
        total -= (200*18) #扣除200斤算18元
        print("==========================最终合计:", total, "元") 
        print("###########################################################################") 

        total = df.iloc[11,11]
        print("==========================虚重:", total, "斤") 
        count = 1123 #篮子数
        print("==========================篮子数:", count, "个") 
        total = (total - count) * 0.97 
        print("==========================净重:", total, "斤") 
        total *= 36 #每斤36元
        print("==========================合计:", total, "元") 
        total -= (200*18) #扣除200斤算18元
        print("==========================最终合计:", total, "元") 
        print("###########################################################################") 


if __name__ == "__main__":
    obj = BaoyuCal()
    obj.testBaoyuCal()


